window.addEventListener('load',function(){
let search=document.querySelector('.search');
let iptList=document.querySelector('#iptList');
let shut=document.querySelector('#inner .icon');

// 头部模块
// 渲染搜索下拉框
fetch("http://39.96.88.57:9090/api/www/search/searchKey?key=&httpsStatus=1&reqId=3d2fd940-d915-11ed-8e03-c7e00f45cb2b").then(res => res.json()).then(res=>{
    for (let i = 0; i < res.data.length; i++) {
           headUl.innerHTML+=`
               <li class="list-item">
                        <a href="#">
                            <span class="id">${i+1}</span>
                            <span class="key_text">${res.data[i]}</span>
                        </a>
                </li>
              `  
    }
    // 获取每个.id 给前三个设置不同的背景
   let ids = document.querySelectorAll('.id');
   ids[0].style.backgroundColor='#ea4343';
   ids[1].style.backgroundColor='#ff6b21';
   ids[2].style.backgroundColor='#ffb700';
  })

    // 搜索框获取焦点和失去焦点事件
    search.addEventListener('click',function(){
        console.log(11);
     iptList.style.height = '443px !important';
     iptList.style.overflow='visible';
    })
    search.addEventListener('focus',function(){
     iptList.style.opacity='1';
     iptList.style.top='35px';
    
     
    })
    search.addEventListener('blur',function (){
    iptList.style.opacity='0';
    iptList.style.top='0';
    })

    // 登录/注册点击事件
    dl.addEventListener('click',function(){
        mask.style.display='block';
    })
    zc.addEventListener('click',function(){
        mask.style.display='block';
    })
    shut.addEventListener('click',function(){
        mask.style.display='none';
    })




})